//
//  WCBaiduPushBindHelp.m
//  WC
//
//  Created by wsj2015 on 16/2/26.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCBaiduPushBindHelp.h"
#import "BPush.h"

@implementation WCBaiduPushBindHelp


+ (void)bindToService{
    
    
    NSMutableDictionary *params =[NSMutableDictionary dictionary];
    //    userType : 1、护士 2、患者
    //    userId : nurseId or patientId
    //    appid,apikey,channelid : 百度云推送消息提供信息
    
   
    Account *account= [[WCDefaultManager shareMg] account];
    if (account) {
        params[@"userType"] =@(1);
        params[@"userId"] = @([[[[WCDefaultManager shareMg] account] stringId] integerValue]);
    }
    
    [BPush getUserId];
    
//    params[@"appid"] =[BPush getAppId];
    params[@"apikey"] =@"xU1Rk8SqQGkaqSzEbw6TtkuL" ;
//    params[@"channelid"] =[BPush getChannelId];
    
//    "app_id" = 7754009;
//    "channel_id" = 5729902180917664298;
  
    [BPush bindChannelWithCompleteHandler:^(NSDictionary *result, NSError *error) {
        if (result[@"channel_id"]) {
            params[@"channelid"] = result[@"channel_id"];
        }
        if (result[@"app_id"]) {
            params[@"appid"] =result[@"app_id"];
            //跟 登陆前公司 服务器绑定
            [[WCNetworkAccessManager sharedMg] POST:kBindpreBind parameters:params success:^(NSDictionary *responseObject) {
                NSLog(@"----%@",responseObject[@"data"]);
                
            } failure:nil netError:nil always:^{
                
            }];
        }
        
    }];
   
   


}

@end
